package yuan.deng.service.impl.store;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.util.StringUtil;
import org.apache.ibatis.session.SqlSession;
import yuan.deng.domain.store.Dept;
import yuan.deng.factory.MapperFactory;
import yuan.deng.mapper.store.DeptMapper;
import yuan.deng.service.store.DeptService;

import java.util.List;

public class DeptServiceImpl implements DeptService {
    @Override
    public List<Dept> findAll(String page) {
        SqlSession sqlSession= null;
        try {
            sqlSession= MapperFactory.getSqlSession();
            DeptMapper deptMapper = MapperFactory.getMapper(sqlSession, DeptMapper.class);
            int i=1;
            if (StringUtil.isNotEmpty(page)){
                i=Integer.parseInt(page);
            }
            PageHelper.startPage(i,5);
            List<Dept> companies = deptMapper.findAll();
            return companies;
        }catch (Exception e){
            e.printStackTrace();
        }finally {
            if (sqlSession!=null){
                sqlSession.close();
            }
        }

        return null;
    }

    @Override
    public void save(Dept c) {

    }

    @Override
    public Dept findById(String id) {
        return null;
    }

    @Override
    public void update(Dept company) {

    }

    @Override
    public void delete(String[] strings) {

    }
}
